package hu.dobrosi.dinkycam.j2me.screens;

import hu.dobrosi.dinkycam.j2me.DinkycamApp;
import hu.dobrosi.dinkycam.j2me.Labels;
import hu.dobrosi.j2me.ui.CustomFontTextCanvas;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

public class DinkycamCanvas extends CustomFontTextCanvas implements
		CommandListener {
	private Command cmdExit;
	private Command cmdSettings;
	private Command cmdLogging;
	DinkycamApp app;

	public DinkycamCanvas() {
	}

	public DinkycamCanvas(DinkycamApp app) {
		super();
		this.app = app;
		buildGUI();
	}

	public void buildGUI() {
		cmdSettings = new Command(Labels.SETTINGS.toString(), Command.EXIT, 100);
		addCommand(cmdSettings);
		cmdLogging = new Command("Debug", Command.EXIT, 200);
		addCommand(cmdLogging);
		cmdExit = new Command(Labels.EXIT.toString(), Command.EXIT, 300);
		addCommand(cmdExit);
		setCommandListener(this);
	}

	public void commandAction(Command c, Displayable s) {
		if (c == cmdExit) {
			app.exit();
		} else if (c == cmdSettings) {
			app.showSettings();
		} else if (c == cmdLogging) {
			app.showLog();
		}
	}
}
